#include <iostream>
#include <memory>
using namespace std;
class Car;
class Person
{

public:
    Person()
    {
        cout << "Person构造函数\n";
    }
    ~Person()
    {
        cout << "Person析构函数\n";
    }

public:
    shared_ptr<Car> m_car = nullptr;
};
class Car
{
public:
    Car()
    {
        cout << "Car构造函数\n";
    }
    ~Car()
    {
        cout << "Car构造函数\n";
    }

public:
#if 1
    weak_ptr<Person> m_person;
#else
    shared_ptr<Car> m_car = nullptr;
#endif
};
int main()
{
    {
        shared_ptr<Person> person(new Person());
        shared_ptr<Car> car(new Car());
        person->m_car = car;
        car->m_person = person;
        cout << person->m_car.use_count() << endl;
        cout << car->m_person.use_count() << endl;
    }
    return 0;
}
/*
    auto_ptr
    shared_ptr
    weak_ptr
    unique_ptr
*/